<template>
    <div>
        <h1>User</h1>
        <h2>{{$route.params.id}}</h2>
        <h2>{{id}}</h2>
    </div>
    <div>
        <button @click="gotoPage">跳转页面</button>
        <br>
        <button @click="GetValue">获取数据</button>
    </div>
    <ul>
        <li v-for="item in lists" :key="item.imgid"><a :href="item.imageurl"> {{item.imageurl}}</a></li>
    </ul>
</template>

<script setup>

import { useRoute, useRouter, onBeforeRouteUpdate, onBeforeRouteLeave } from 'vue-router'
import { ref } from 'vue'
import axios from 'axios'
// let id = useRoute().params.id
const router = useRouter()
function gotoPage() {
    router.replace("/")
}
const props = defineProps({
    id: String
})

const lists = ref([])

function GetValue() {
    // fetch('https://console-mock.apipost.cn/mock/103e3762-7e66-4a89-a126-37e9a24f025a/').
    //     then((res) => {
    //         // console.log(res.json());
    //         return res.json()
    //     }).then((res) => {
    //         lists.value = res.list
    //         console.log(res);
    //     })
    axios.get('/path/api/mmdb/movie/v3/list/hot.json?ct=上海&ci=10&channelId=4').
        then((res) => {
            console.log(res.data);
            // lists.value = res.data.list
        }).catch((err) => {
            console.log(err);
        })
}

</script>

<!-- <script>
import axios from 'axios'
export default {
    props: ['id'],
    data() {
        return {
            lists: []
        }
    },
    methods: {
        GetValue() {
            // fetch('https://console-mock.apipost.cn/mock/103e3762-7e66-4a89-a126-37e9a24f025a/').
            //     then((res) => {
            //         // console.log(res.json());
            //         return res.json()
            //     }).then((res) => {
            //         this.lists = res.list
            //         console.log(res);
            //     })
            axios.get('https://console-mock.apipost.cn/mock/103e3762-7e66-4a89-a126-37e9a24f025a/').
                then((res) => {
                    console.log(res.data);
                    this.lists = res.data.list
                }).catch((err) => {
                    console.log(err);
                })
        }
    } 
}
</script> -->



